package com.itheima.mq;


import com.itheima.constatns.MqConstants;
import com.itheima.service.ItemService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemListener {
    @Autowired
    private ItemService itemService;

    /**
     * 监听商品新增或修改的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = MqConstants.ITEM_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Long id){
        itemService.insertById(id);
    }

    /**
     * 监听商品删除的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = MqConstants.ITEM_DELETE_QUEUE)
    public void listenHotelDelete(Long id){
        itemService.deleteById(id);
    }

}
